package com.chagee.channel.api.enums;

import com.alibaba.fastjson.parser.DefaultJSONParser;
import com.alibaba.fastjson.parser.JSONToken;
import com.alibaba.fastjson.parser.deserializer.ObjectDeserializer;
import java.lang.reflect.Type;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author: chang.jiawei
 * @date: 2024/01/24
 */
@AllArgsConstructor
@Getter
public enum LarkApprovalStatusEnum {

    PENDING("审批中"),
    APPROVED("通过"),
    REJECTED("拒绝"),
    CANCELED("撤回"),
    DELETED("删除"),
    REVERTED("已撤销"),
    OVERTIME_CLOSE("超时被关闭"),
    OVERTIME_RECOVER("超时实例被恢复"),
    ;

    private final String desc;

    public static class LarkApprovalStatusDeserializer implements ObjectDeserializer {

        @SuppressWarnings("unchecked")
        @Override
        public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
            String status = parser.parseObject(type);
            return (T) LarkApprovalStatusEnum.valueOf(status);
        }

        @Override
        public int getFastMatchToken() {
            return JSONToken.LITERAL_STRING;
        }
    }
}
